<template>
  <div class="card">
    <div class="card-header">
      <div class="card-header__left">
        <div class="card-header__index">
          {{info.index}}
        </div>
        <div class="subTitle card-header__title">
          <span>{{info.title}}</span>
        </div>
      </div>
      <div class="card-header__right">
        <img :data-src="info.imgUrl"/>
      </div>
    </div>
    
    <div class="text card-main">
        {{info.introduction}}
    </div>
    
    <ul class="card-footer">
      <li class="card-footer__title">
        <span>特点</span>
      </li>
      <ul class="card-footer__content">
        <li
          :class="index===0 ? '': 'card-footer__content__item'"
          v-for="(feature, index) of info.features"
          :key="index"
        >
          <span class="card-footer__content__item-figure">{{ fix(index+1, 2) }}</span>
          <span class="card-footer__content__item-text">{{feature}}</span>
        </li>
      </ul>
    </ul>
  </div>
</template>

<script>
export default {
  name: "Card",
  props: ['info'],
  data() {
    return {
    }
  },
  methods:{
    fix(num, length) {
      return ('' + num).length < length ? ((new Array(length + 1)).join('0') + num).slice(-length) : '' + num;
    }
  }
}
</script>

<style scoped lang="scss">
  $light-yellow: #F0DFB3;
  $dark-yellow: #DCB613;
  $blue: #177CB2;
  
  .subTitle{
    font-size: 25px;
    font-weight: bold;
  }

  .text{
    line-height: 1.5em;
  }

  .card{
    width: 80%;
    padding: 60px 50px 50px 50px;
    box-shadow: 0px 50px 50px rgb(0 0 0 / 10%);
    border-radius: 30px;

    .card-header{
      display: flex;
      justify-content: space-between;
      align-items: flex-end;

      .card-header__left{
        .card-header__index{
          font-weight: bold;
        }

        .card-header__title{
          padding: 20px 0;
          font-family: sans-serif;
          color: $blue;

          span{
            border-bottom: 1px solid $light-yellow;
          }
        }
      }
      .card-header__right{
        width: 60%;
        img{
          width: 100%;
          min-height: 50px;
        }
      }
    }

    .card-main{
      margin: 10px 0;
    }

    .card-footer{
      margin-top: 20px;

      .card-footer__title{
        list-style: inside;
        font-weight: bold;
        color: $dark-yellow;
        span{
          color: $blue;
        }
      }

      .card-footer__content{
        list-style: none;

        .card-footer__content__item{
          border-top: 1px dashed $dark-yellow;
        }
        li{
          padding: 10px 0;
          .card-footer__content__item-figure{
            color: $blue;
            font-weight: bold;
          }
          .card-footer__content__item-text{
            padding: 0 10px;
          }
        }
      }
    }
  }
</style>
